<template>
	<view class="acceleration_details">
		<view class="menu-view">
			<view class="menu_item" :class="current == menu_index ? 'native' : ''"
				v-for="(menu_item ,menu_index) in menus" :key="menu_index" @click.stop="selectIndex(menu_index)">
				{{menu_item}}
			</view>
		</view>
		<mescroll-uni @getData="getData" ref="mescroll" top="98">
			<block slot="list">
				<block v-if="dataList.length > 0">
					<view class="list-box">
						<view class="list-item" v-for="(item,index) in dataList" :key="">
							<view class="part-one">
								<view class="part-one-left">
									<view class="type_label">{{item.type == 0 ? '到店' : '分享'}}</view>
									<view class="order_label">{{item.order_no}}</view>
								</view>
								<view class="acc-num">加速补贴{{item.practical_value}}</view>
							</view>
							<view class="gray_box">
								<block v-if="item.status == 0">
									<view class=""></view>
									<view class="daijiasu">待加速</view>
								</block>
								<block v-else>
									<view class="gra_dec_title">加速订单</view>
									<view class="gra_dec_title">{{item.accelerated_no}}</view>
								</block>
							</view>
							<view class="item-foot">
								<view class="foot-left">
									<image class="head_img" :src="$util.img(item.headimg)" mode="aspectFill"></image>
									<view class="name_label">{{item.nickname}}</view>
								</view>
								<view class="time-text">{{$util.timeStampTurnTime(item.create_time)}}</view>
							</view>
						</view>
					</view>
				</block>
				<block v-else>
					<ns-empty :isIndex="false" :fixed="true" text="暂无数据"></ns-empty>
				</block>
			</block>
		</mescroll-uni>
		<loading-cover ref="loadingCover"></loading-cover>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				menus: ['全部', '已加速', '待加速'],
				current: 0,
				dataList: []
			}
		},
		methods: {
			getData(mescroll) {
				this.$api.sendRequest({
					url: '/expansion/api/Record/accelerateDetailPage',
					data: {
						page: mescroll.num,
						page_size: mescroll.size,
						type: this.current
					},
					success: res => {
						let newArr = [];
						let msg = res.message;
						if (res.code == 0 && res.data) {
							newArr = res.data.list;
						} else {
							this.$util.showToast({
								title: msg
							});
						}
						if (mescroll.endSuccess) mescroll.endSuccess(newArr.length);
						//设置列表数据
						if (mescroll.num == 1) this.dataList = []; //如果是第一页需手动制空列表
						this.dataList = this.dataList.concat(newArr); //追加新数据
						// this.$forceUpdate();
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					},
					fail() {
						//联网失败的回调
						if (mescroll.endErr) mescroll.endErr();
						if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
					}
				})
			},
			selectIndex(index) {
				if (this.current != index) {
					this.current = index;
					this.$refs.mescroll.refresh();
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.acceleration_details {
		.menu-view {
			width: 100vw;
			height: 98rpx;
			display: flex;
			align-items: center;

			.menu_item {
				width: 33%;
				height: 100%;
				display: flex;
				align-items: center;
				justify-content: center;

				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;

				&.native {
					font-weight: 500;
					font-size: 32rpx;
				}
			}
		}

		.list-box {
			padding: 0 24rpx;

			.list-item {
				padding: 28rpx 24rpx 12rpx 24rpx;
				background-color: #fff;
				border-radius: 20rpx;
				margin-bottom: 24rpx;

				.part-one {
					display: flex;
					align-items: center;
					justify-content: space-between;

					.part-one-left {
						display: flex;
						align-items: center;

						.type_label {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 22rpx;
							color: #FFFFFF;
							background-color: #004FC6;
							border-radius: 4rpx;
							padding: 0 8rpx;
							line-height: 32rpx;
						}

						.order_label {
							margin-left: 8rpx;
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 28rpx;
							color: #666666;
							line-height: 40rpx;
						}
					}

					.acc-num {
						font-family: PingFang SC, PingFang SC;
						font-weight: 500;
						font-size: 28rpx;
						color: #F53F3F;
						line-height: 40rpx;
					}
				}

				.gray_box {
					width: 100%;
					height: 56rpx;
					border-radius: 4rpx;
					background-color: #F2F3F5;
					margin-top: 24rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;
					padding: 0 16rpx;

					.daijiasu {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						color: #F53F3F;
						line-height: 40rpx;
					}

					.gra_dec_title {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						color: #222222;
						line-height: 34rpx;
					}
				}

				.item-foot {
					margin-top: 28rpx;
					display: flex;
					align-items: center;
					justify-content: space-between;

					.foot-left {
						display: flex;
						align-items: center;

						.head_img {
							width: 40rpx;
							height: 40rpx;
							border-radius: 50%;
							margin-right: 8rpx;
						}

						.name_label {
							font-family: PingFang SC, PingFang SC;
							font-weight: 400;
							font-size: 24rpx;
							color: #666666;
							line-height: 34rpx;
						}
					}

					.time-text {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #999999;
						line-height: 34rpx;
					}
				}
			}
		}
	}

	page {
		background-color: #F2F3F5;
	}

	view {
		box-sizing: border-box;
	}
</style>